1。アプリケーションのデプロイ
アプリケーションを作成し、起動時に自動的に開始するようにする必要がよくあります。これは、Systemd サービスをセットアップすることで実現できます。以下では、単純な hello.service の作成を例として使用し、ArmSoM ボード上で独自の Systemd サービスをセットアップする手順を説明します。
1.1 スクリプトを書く
/opt ディレクトリに hello.sh スクリプトを作成します。
#!/bin/bash
for ((i=1; i<=3; i++))
do
echo "hello,armsom!" >> /tmp/hello.log
sleep 1
done
このスクリプトで実装される機能は、「Hello, ArmSoM!」というメッセージを出力することです。文字列を毎秒 3 回 /tmp/wello.log ファイルに書き込みます。
スクリプトに実行権限を追加します。
chmod +x hello.sh
1.2 プロフィールを作成
hello armom を作成します。 /etc/systemd/system/ディレクトリ内のサービス構成ファイル:
[Unit]
Description=Hello Armsom Service
After=network.target
[Service]
Type=simple
User=armsom
ExecStart=/opt/hello.sh
Restart=no
StandardOutput=journal
[Install]
WantedBy=multi-user.target
ExecutStart フィールドは、hello armsom の自己起動スクリプトを定義します。サービスサービスとして/opt/hello.sh。 hello を有効にすると、起動後にサービス起動関数/opt/hello.shが実行されます
1.3 hello-armsom.service を有効にする
'sudo systemctl list unit files - type=service | grep hello' コマンドを入力し、hello.service がサービス一覧に追加されているか確認します。
armsom@armsom:/etc/systemd/system$ sudo systemctl list-unit-files --type=service | grep hello
hello-armsom.service disabled enabled
こんにちは。サービスは無効な状態です。上記のコマンドを入力しても何も表示されない場合は、作成したサービスに問題があるため、慎重に調査する必要があります。 systemd をリロードしてサービスを有効にします。
# Reload systemd configuration
sudo systemctl daemon-reload
# Enable self startup upon startup
sudo systemctl enable hello-armsom.service
# Start the service immediately
sudo systemctl start hello-armsom.service
# View service status
sudo systemctl status hello-armsom.service
# View service logs
sudo journalctl -u hello-armsom.service -f
上記のコマンドを入力して、「Hello」と表示されることを確認します。サービスが実行中です
armsom@armsom:~$ sudo systemctl status hello-armsom.service
○ hello-armsom.service - Hello Armsom Service
Loaded: loaded (/etc/systemd/system/hello-armsom.service; enabled; preset: enabled)
Active: inactive (dead) since Thu 2026-01-08 11:30:33 CST; 3s ago
Duration: 3.059s
Process: 3510 ExecStart=/opt/hello.sh (code=exited, status=0/SUCCESS)
Main PID: 3510 (code=exited, status=0/SUCCESS)
CPU: 15ms
armsom@armsom:~$
armsom@armsom:~$ cat /tmp/hello.log
hello,armsom!
hello,armsom!
hello,armsom!
2.deb パッケージをインストールします
Deb パッケージは、Linux システムのインストール パッケージです。オンラインでダウンロードされた Linux ソフトウェア インストール パッケージが deb パッケージの形式で表示される場合もあります。 tar パッケージに基づいているため、ファイルの権限情報 (読み取り、書き込み、実行可能)、所有者、ユーザー グループなども記録されます。
次のコマンドを使用します。 dpkg - l システムとインストールされている deb パッケージを表示します。
2.1 debパッケージの構成構造
Deb パッケージは通常、次の 2 つの部分に分かれています。
- インストール内容は Linux のルート ディレクトリに似ており、ソフトウェアを Linux システムのファイル ディレクトリにインストールする必要があることを示しています。
- 制御情報 (DEBIAN ディレクトリに置かれます)。通常、DEBIAN ディレクトリには次のようないくつかのファイルがあります。
- 変更ログ: このファイルには、deb パッケージの作成者、バージョン、最終更新日などの情報が記録されます。
- コントロール: ファイルには、パッケージ名、バージョン番号、アーキテクチャ、メンテナ、説明などの情報が記録されます。
- 著作権: ファイルには著作権情報が記録されています。
- ポストスクリプト: 通常のディレクトリファイルをシステムにコピーした後にソフトウェアが実行する必要があるスクリプト。
- Postrm ファイル: ソフトウェアのアンインストール後に実行する必要があるスクリプト。
- このうち、コントロール、ポスター、ポスターは必要なファイルです。
2.2 deb パッケージをビルドする
インストールツールと依存関係:
sudo apt-get install build-essential debhelper make autoconf automake dpkg-dev fakeroot pbuilder gnupg
次のディレクトリとファイルを作成します。
armsom@armsom:~$ tree armsom-service/
armsom-service/
├── DEBIAN
│ ├── control
│ ├── postinst
│ └── postrm
├── etc
│ └── systemd
│ └── system
│ └── hello-armsom.service
└── opt
└── hello.sh
6 directories, 5 files
DEBIAN/コントロール:
Package: armsom-service
Version: 1.0.0-1
Section: utils
Priority: optional
Architecture: arm64
Depends: bash, systemd
Maintainer: armsom <armsom@example.com>
Description: Armsom
postinst:
#!/bin/bash
if [ "$1" = "upgrade" ] || [ "$1" = "install" ];then
echo "armsom-service installing"
if [ -f "/opt/hello.sh" ]; then
chmod +x /opt/hello.sh
echo "✓ The execution permission of/opt/hello.sh has been set"
fi
systemctl enable hello-armsom
systemctl start hello-armsom
fi
postrm
#!/bin/bash
if [ "$1" = "upgrade" ] ; then
echo "upgrade"
elif [ "$1" = "remove" ] || [ "$1" = "purge" ] ; then
echo "remove armsom-service"
systemctl stop hello-armsom.service
systemctl disable hello-armsom.service
fi
上記のディレクトリを deb ファイルにパッケージ化し、dpkg コマンドを使用してボードにインストールします。
dpkg-deb --build -Zgzip armsom-service armsom-service.deb
sudo dpkg -i armsom-service.deb
2.3 deb パッケージを変更する
一般的な方法は次のとおりです。
#Extract the file from the package to the extract/ directory
dpkg -X rkwifibt-broadcom-firmware_1.0.0-1_arm64.deb extract/
#Extract the control information of the extracted package to the extract/DEBIAN/ directory
dpkg -e rkwifibt-broadcom-firmware_1.0.0-1_arm64.deb extract/DEBIAN/
#Modify file xxx
#Repackage the modified content
dpkg-deb --build -Zgzip extract/ *****.deb
